﻿using TI_BLE_HCI_ClientLib.BaseEntities;
using TI_BLE_HCI_ClientLib.GenericHCIEntities;
using TI_BLE_HCI_ClientLib.HCIBaseEntities;

namespace TI_BLE_HCI_ClientLib.HCICommands
{
    public class HCICommand_GAP_Terminate_Link_Request : HCIVendorSpecificCommand
    {
        private const byte CMD = 0xa;

        public const ushort CONN_HANDLE_TERMINATE_ESTABLISH_LINK_REQUEST = (ushort)0xfffe;
        public const ushort CONN_HANDLE_TERMINATE_ALL_LINKS = (ushort)0xffff;

        public enum ReasonEnum
        {
            AuthenticationFailure=0x05,
            RemoteUserTerminatedConnection=0x13,
            RemoteDeviceTerminatedConnectionDueToLowResources=0x14,
            RemoteDeviceTerminatedConnectionDueToPowerOff = 0x15,
            UnsupportedRemoteFeature=0x1a,
            PairingWithUnitKeyNotSupported=0x29,
            UnacceptableConnectionInterval=0x3b
        }

        public enum Return_Status
        {
            Success = 0,
            NoLinkToTerminate=0x12
        }

        public HCICommand_GAP_Terminate_Link_Request(ushort connHandle, ReasonEnum reason)
            : base(HCIVendorSpecificCommandCSG.GAP, CMD)
        {
            var pars = new BaseEntityParameter[2];

            pars[0] = new WordParameter(connHandle);
            pars[1] = new ByteParameter((byte)reason);

            base.addParameters(pars);
        }
    }
}